consistent quoting of import Base.:operator and warnings thereof #33158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR: This PR allows quoting in
import
statements, e.g.import Base.:+
, similar to other Julia contexts, and uses quoting forMethodError
warnings about shadowed operators.As was noted recently on discourse, the
MethodError
printing currently shows a potentially confusing suggestion when a function shadows aBase
function if it is an operator, and in general the quoting of symbols (e.g.Base.+
vs.Base.:+
) was a bit inconsistent.For example, if you accidentally shadow
+
, it printsYou may have intended to import Base.+
, which may be confusing because if you try to define the function asBase.+
Julia will give an error. This PR changes the error message to quote operators.Unfortunately, while
function Base.:+(...)
works,import Base.:+
gave a syntax error, which seems a little inconsistent. So this PR also updates the parser to allow quoted symbols inimport
statements. Backwards compatible since it was a syntax error previously.